using System;
using System.Data.Linq;
using System.Data.Linq.Mapping;
using System.IO;
using System.Windows;
using System.Windows.Resources;
namespace MicroMsg.Storage
{
	public class ChatMsgMapping : StorageMapping
	{
		private static string strMapping;
		private XmlMappingSource mapping;
		public ChatMsgMapping(string tabName)
		{
			string xmlMappingString = this.getXmlMappingString();
			this.mapping = XmlMappingSource.FromXml(string.Format(xmlMappingString, tabName, typeof(ChatMsg).get_Name()));
		}
		private string getXmlMappingString()
		{
			if (ChatMsgMapping.strMapping != null)
			{
				return ChatMsgMapping.strMapping;
			}
			StreamResourceInfo resourceStream = Application.GetResourceStream(new Uri("Resource/Xml/ChatMsgMapping.xml", 2));
			using (StreamReader streamReader = new StreamReader(resourceStream.get_Stream()))
			{
				ChatMsgMapping.strMapping = streamReader.ReadToEnd();
			}
			return ChatMsgMapping.strMapping;
		}
		public override DataContext getDB()
		{
			DataContext dataContext = this.newDB();
			dataContext.set_ObjectTrackingEnabled(false);
			return dataContext;
		}
		public override DataContext newDB()
		{
			return new DataContext(StorageDB.db_setting, this.mapping);
		}
	}
}
